package jukebox.model.qnaboard;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class QnABoardDAOImpl implements QnABoardDAO {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public void writeContent(QnABoardVO bvo) {
		sqlSessionTemplate.insert("qnaboard.writeContent", bvo);
	}

	@Override
	public int getCurrentNo() {
		return sqlSessionTemplate.selectOne("qnaboard.getCurrentNo");
	}

	@Override
	public void updateContent(QnABoardVO bvo) {
		sqlSessionTemplate.update("qnaboard.updateContent", bvo);
	}

	@Override
	public void deleteContent(int no) {
		sqlSessionTemplate.delete("qnaboard.deleteContent", no);
	}

	@Override
	public List<QnABoardVO> findContentListByTitle(Map<String, Object> map) {
		return sqlSessionTemplate.selectList("qnaboard.findContentListByTitle", map);
	}

	@Override
	public int getFindContentCount(String title) {
		return sqlSessionTemplate.selectOne("qnaboard.getFindContentCount", title);
	}

	@Override
	public List<QnABoardVO> getContentListPerPage(Map<String, Object> map) {
		return sqlSessionTemplate.selectList("qnaboard.getContentListPerPage", map);
	}

	@Override
	public int getContentCount(String title) {
		return sqlSessionTemplate.selectOne("qnaboard.getContentCount", title);
	}

	@Override
	public QnABoardVO findContentByNo(int no) {
		return sqlSessionTemplate.selectOne("qnaboard.findContentByNo", no);
	}
	
	@Override
	public void IncreaseHit(int no) {
		sqlSessionTemplate.update("qnaboard.IncreaseHit", no);
	}
	

}
